package ejb.entity;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Set;


/**
 * The persistent class for the positions database table.
 * 
 */
@Entity
@Table(name="positions")
@NamedQueries({
	@NamedQuery(name="DefaultPosition.findAll", query="SELECT pos FROM DefaultPosition pos"),
	@NamedQuery(name="DefaultPosition.findById", query="SELECT pos FROM DefaultPosition pos WHERE pos.id = :id"),
	@NamedQuery(name="DefaultPosition.findByUser", query="SELECT pos FROM DefaultPosition pos WHERE pos.user = :user"),
	@NamedQuery(name="DefaultPosition.findByName", query="SELECT pos FROM DefaultPosition pos WHERE pos.name = :name"),
	@NamedQuery(name="DefaultPosition.findByNameAndUser", query="SELECT pos FROM DefaultPosition pos WHERE pos.name = :name AND pos.user = :user"),
	@NamedQuery(name="DefaultPosition.findByUserAndForecast", query="SELECT pos FROM DefaultPosition pos WHERE pos.user = :user AND pos.forecast = :forecast")
})
public class DefaultPosition implements Serializable, Position {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int id;

	private String name;

	private int positionx;

	private int positiony;

	//bi-directional many-to-one association to DefaultNotification
	@OneToMany(mappedBy="position", targetEntity=DefaultNotification.class, cascade = {CascadeType.REMOVE})
	private Set<Notification> notifications;

	//bi-directional many-to-one association to DefaultUser
    @ManyToOne(targetEntity=DefaultUser.class)
	@JoinColumn(name="user_id")
	private User user;

    private boolean forecast;
    
    public DefaultPosition() {
    }
    
    public DefaultPosition(String position_name, int x, int y, User user) {
    	this.name = position_name;
    	this.positionx = x;
    	this.positiony = y;
    	this.user = user;
    }    

	/* (non-Javadoc)
	 * @see ejb.entity.Position#getId()
	 */
	@Override
	public int getId() {
		return this.id;
	}

	/* (non-Javadoc)
	 * @see ejb.entity.Position#setId(int)
	 */
	@Override
	public void setId(int id) {
		this.id = id;
	}

	/* (non-Javadoc)
	 * @see ejb.entity.Position#getName()
	 */
	@Override
	public String getName() {
		return this.name;
	}

	/* (non-Javadoc)
	 * @see ejb.entity.Position#setName(java.lang.String)
	 */
	@Override
	public void setName(String name) {
		this.name = name;
	}

	/* (non-Javadoc)
	 * @see ejb.entity.Position#getPositionx()
	 */
	@Override
	public int getPositionx() {
		return this.positionx;
	}

	/* (non-Javadoc)
	 * @see ejb.entity.Position#setPositionx(int)
	 */
	@Override
	public void setPositionx(int positionx) {
		this.positionx = positionx;
	}

	/* (non-Javadoc)
	 * @see ejb.entity.Position#getPositiony()
	 */
	@Override
	public int getPositiony() {
		return this.positiony;
	}

	/* (non-Javadoc)
	 * @see ejb.entity.Position#setPositiony(int)
	 */
	@Override
	public void setPositiony(int positiony) {
		this.positiony = positiony;
	}

	/* (non-Javadoc)
	 * @see ejb.entity.Position#getNotifications()
	 */
	@Override
	public Set<Notification> getNotifications() {
		return this.notifications;
	}

	/* (non-Javadoc)
	 * @see ejb.entity.Position#setNotifications(java.util.Set)
	 */
	@Override
	public void setNotifications(Set<Notification> notifications) {
		this.notifications = notifications;
	}
	
	/* (non-Javadoc)
	 * @see ejb.entity.Position#getUser()
	 */
	@Override
	public User getUser() {
		return this.user;
	}

	/* (non-Javadoc)
	 * @see ejb.entity.Position#setUser(ejb.entity.DefaultUser)
	 */
	@Override
	public void setUser(User user) {
		this.user = user;
	}
	
	@Override
	public boolean isForecast() {
		return forecast;
	}
	
	@Override
	public void setForecast(boolean forecast) {
		this.forecast = forecast;
	}
	
	
	
}